package com.kotiln.lgc.lib_network.interceptor

import android.util.Log
import okhttp3.Interceptor
import okhttp3.Request
import okhttp3.Response

/**
 *@fileName HttpInterceptor
 *@date2021/1/25  16:51
 *@author LGC
 *@describe TODO HttpInterceptor$
 *@desc 拦截器 / 作用:重定向  请求头  加密 解密
 */
class HttpInterceptor:Interceptor {

    private val TAG:String="HTTP"
    override fun intercept(chain: Interceptor.Chain): Response {
        //请求参数
        val request: Request =chain.request()
        val response:Response=chain.proceed(request)

        Log.i(TAG,"============REQUEST===============")
        if(request.method() == "GET"){
            Log.i(TAG,request.body().toString())
            Log.i(TAG,request.url().toString())
        }

        Log.i(TAG,"============RESPONSE===============")
        response.body()?.let {
            Log.i(TAG,it.string())
        }
        return response
    }

}